
$(document).ready(function() {
    getCampaign();
    $("#edit-organization").change(function() {
        getCampaign();
    });


});

function getCampaign() {
    var pageUrl = 'http://' + document.domain;
    var orgId = $("#edit-organization").val();
    var extraLink = '';
    if(pageUrl == 'http://localhost'){
        extraLink = '/fundraisingmagsdev';
    }
    else{
        extraLink = '';
    }
    $.getJSON(pageUrl + extraLink+ '/order_export/reports/get_cam_list/' + orgId, function(json) {
           
        $("option", $("#edit-campaign")).remove();

        $.each(json, function(index, array) {
            var option = "<option value='" + array['id'] + "'>" + array['title'] + "</option>";
            $("#edit-campaign").append(option);
        });
    });
    
}
